// import Home from '@/views/Home'
// import Login from '@/views/Login'
// import Register from '@/views/Register'
// import Search from '@/views/Search'
// import Detail from '@/views/Detail'
// import AddCartSuccess from '@/views/AddCartSuccess'
// import ShopCart from '@/views/ShopCart'
// import Trade from '@/views/Trade'
// import Pay from '@/views/Pay'
// import PaySuccess from '@/views/PaySuccess'
// import Center from '@/views/Center'
import MyOrder from '@/views/Center/myOrder'
import GroupOrder from '@/views/Center/groupOrder'

export default [
  { 
    path: '/center', 
    component: () => import ('@/views/Center'), 
    meta: { show: true }, 
    name: 'Center',
    children: [
      {
        path: 'myorder',//二级没有/
        component: MyOrder
      },
      {
        path: 'grouporder',
        component: GroupOrder
      },
      {
        path: '/center',
        redirect: '/center/myorder'
      }
    ]
  },
  { path: '/paysuccess', component: () => import ('@/views/PaySuccess'), meta: { show: true }, name: 'PaySuccess'},
  { 
    path: '/pay', 
    component: () => import ('@/views/Pay'), 
    meta: { show: true }, 
    name: 'Pay',
    // 路由独享守卫： 去到pay页 必须得从trade那来
    beforeEnter: (to, from, next) => {
      if (from.path == '/trade') {
        next ()
      } else {
        next (false) // 中断跳转 从哪来回哪去
      }
    }
  },
  { 
    path: '/trade', 
    component: () => import ('@/views/Trade'), 
    meta: { show: true }, 
    name: 'Trade',
    // 路由独享守卫： 去到trade页 必须得从购物车结算那来
    beforeEnter: (to, from, next) => {
      if (from.path == '/shopcart') {
        next ()
      } else {
        next (false) // 中断跳转 从哪来回哪去
      }
    }
  },
  { path: '/shopcart', component: () => import ('@/views/ShopCart'), meta: { show: true }, name: 'ShopCart'},
  { path: '/addcartsuccess', component: () => import ('@/views/AddCartSuccess'), meta: { show: true }, name: 'addcartsuccess'},
  { path: '/home', component: () => import ('@/views/Home'), meta: { show: true } },
  { path: '/detail/:skuid', component: () => import ('@/views/Detail'), meta: { show: true } },
  {
    path: '/search/:keyword?',
    component: () => import ('@/views/Search'),
    meta: { show: true },
    name: 'search',
    // 路由组件能不能传递props数据--可以
    // props: true
    // props: {a:1, b:2}
  },
  { path: '/login', component: () => import ('@/views/Login'), meta: { show: false } },
  { path: '/register', component: () => import ('@/views/Register'), meta: { show: false } },
  { path: '/', redirect: '/home' },
]